// 导入已配置的axios实例
import service from '../utils/request';

/**
 * 上传文件
 * @param {File} file - 要上传的文件
 * @param {Object} options - 上传选项
 * @param {Function} options.onUploadProgress - 上传进度回调函数
 * @returns {Promise}
 */
export function uploadFile(file, options = {}) {
  const formData = new FormData();
  formData.append('file', file);
  return service({
    url: '/uploadImage',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    onUploadProgress: options.onUploadProgress || null
  });
}